<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:xdb="http://orbeon.org/oxf/xml/xmldb" xmlns:xu="http://www.xmldb.org/xupdate">

	<p:param type="output" name="data"/>

	<p:processor name="oxf:request">
		<p:input name="config">
			<config >
				<include>/request/parameters</include>
			</config>
		</p:input>
		<p:output name="data" id="request"/>
	</p:processor>

	<p:processor name="oxf:xslt">
		<p:input name="data" href="#request"/>
		<p:output name="data" id="query"/>
		<p:input name="config">
			<xdb:update xsl:version="2.0" collection="/db/portal">
				<xu:modifications version="1.0">
					<xu:variable name="tget" select="/widgetsList//widget[@id='{//parameter[name='widget']/value}']/visible"/>
					<xu:update select="$tget">
						<xu:value-of select="(number($tget) + 1) mod 2"/>
					</xu:update>
				</xu:modifications>
			</xdb:update>
		</p:input>
	</p:processor>

	<p:processor name="oxf:xmldb-update">
		<p:input name="datasource" href="/config/datasource.xml"/>
		<p:input name="query" href="#query"/>
	</p:processor>

	<p:processor name="oxf:pipeline">
		<p:input name="config" href="../widget.xpl"/>
		<p:output name="data" id="datas"/>
	</p:processor>

	<p:processor name="oxf:identity">
		<p:input name="data">
			<message>The visibility of the widget has been successfuly changed.</message>
		</p:input>
		<p:output name="data" id="message"/>
	</p:processor>
	<p:processor name="oxf:identity">
		<p:input name="data" href="aggregate('data', #message, #datas#xpointer(/data/*))"/>
		<p:output name="data" ref="data"/>
	</p:processor>
</p:config>